package com.example.demo.service;

import com.example.demo.entity.Userinfo;
import com.example.demo.mapper.UserMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

@Service
public class UserService {

    @Resource
    private UserMapper userMapper;

    public int reg(Userinfo userinfo){
        return userMapper.reg(userinfo);
    }


    public Userinfo getUserByName(String username){
        return userMapper.getUserByName(username);
    }


    public Userinfo gerUserById(Integer id){
        return userMapper.gerUserById(id);
    }

    //用户state+1
    public int updateStateAdd(Integer id){
        return userMapper.updateStateAdd(id);
    }

    //将用户字段恢复为1
    public int updateStateToOne(Integer id){
        return userMapper.updateStateToOne(id);
    }

    //根据用户id获取用户名
    public Userinfo getUserById(Integer uid) {
        return userMapper.getUserById(uid);
    }

    //根据rid获取uid
    public int getUidByRid(Integer rid) {
        return userMapper.getUidByRid(rid);
    }

    //更新头像信息
    public int updatePhotoById(Integer id, String photoPathRe) {
        return userMapper.updatePhotoById(id,photoPathRe);
    }
}
